import request from '@/utils/request';


//原来的
// export function fetchDeviceList() {
//     return request({
//         url: 'device-list/',
//     });
// }

// export function updateDevice(device_id, data) {
//     return request({
//         url: `device-list/${device_id}/`,
//         method: 'put',
//         data,
//     });
// }

export function fetchDeviceList() {
    if(localStorage.getItem('user')){
        var  user=JSON.parse(localStorage.getItem('user')).username;
        var  company_id=JSON.parse(localStorage.getItem('user')).company_id;
    }
  return request({
    url: `device_list/?company_id=${company_id}&user=${user}`,
  });
}

export function updateDevice(device_id, data) {
    data.device_id=device_id;
    return request({
    url: `device_list/`,
    method: 'put',
    data,
  });
}

export function createDevice(data) {
    return request({
        url: `device-list/`,
        method: 'post',
        data,
    });
}

export function deleteDevice(device_id) {
    return request({
        url: `device-list/${device_id}/`,
        method: 'delete',
    });
}
